import { Public } from '@/decorators/visit.decorator';
import { Controller, Delete, Get, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { WordService } from './word.service';

@ApiTags('词汇管理')
@Controller('admin/word')
export class WordController {
  constructor(private readonly wordService: WordService) {}

  @Public()
  @ApiOperation({
    summary: '词汇列表查询',
  })
  @ApiBearerAuth()
  @Get('/wordListSelect')
  wordListSelect(
    @Query('page') page = 1,
    @Query('size') size = 10,
    @Query('dictionaryId') dictionaryId = 0,
    @Query('content') content = '',
  ) {
    return this.wordService.wordListSelect({
      page: Number(page),
      size: Number(size),
      dictionaryId: dictionaryId,
      content,
    });
  }

  @Public()
  @ApiOperation({
    summary: '删除单词',
  })
  @ApiBearerAuth()
  @Delete('/deleteWord')
  deleteWord(@Query('id') id: number) {
    return this.wordService.deleteWord(id);
  }
}
